﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using RedisDemo.Redis.Base;
using RedisDemo.Service.IServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace RedisDemo.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class PanicBuyingController : ControllerBase
    {
        private readonly IPanicBuyingService _panicBuyingService;
        private readonly RedisConfig _redis;

        public PanicBuyingController(IPanicBuyingService panicBuyingService, RedisConfig redis)
        {
            _panicBuyingService = panicBuyingService;
            _redis = redis;
        }

        [HttpPost, Route("InsertCommodity")]
        public async Task<bool> InsertCommodity(long Num)
        {
            return await _panicBuyingService.InsertCommodity(Num);
        }

        [HttpPost,Route("PanicBuying")]
        public async Task<bool> PanicBuying(int Id)
        {
            for (int i = 0; i < 1000; i++)
            {
                await _panicBuyingService.PanicBuying(i);
            }
            return true;
        }

    }
}
